<?php
/**
 * Introduction: 专题接口
 * @author: 杨陈鹏
 * @email: yangchenpeng@cdlinglu.com
 */
namespace WeChat\Controller\Special;

use Think\Controller;

class IndexController extends Controller
{

    /**
     * Introduction: 专题列表
     * @author: 杨陈鹏
     * @email: yangchenpeng@cdlinglu.com
     */
    public function lists()
    {

        $logic = D('Common/Special','Logic');

        $page = I('post.page',1);

        $nums = I('post.nums',20);

        outPut($logic::getData([],'*','create_time desc',$page,$nums));


    }
    /**
     * Introduction: 专题详情
     * @author: 杨陈鹏
     * @email: yangchenpeng@cdlinglu.com
     */
    public function detail()
    {

        $logic = D('Common/Special','Logic');

        $data = I('post.data');

        outPut($logic::getOneData($data['id'],'*'));


    }
    /**
     * Introduction: 专题点赞
     * @author: 杨陈鹏
     * @email: yangchenpeng@cdlinglu.com
     */
    public function like()
    {

        $logic = D('Common/Special','Logic');

        $data = I('post.data');

        outPut($logic::like($data['id']));


    }
    /**
     * Introduction: 专题浏览次数
     * @author: 杨陈鹏
     * @email: yangchenpeng@cdlinglu.com
     */
    public function views()
    {

        $logic = D('Common/Special','Logic');

        $data = I('post.data');

        outPut($logic::views($data['id']));

    }

    /**
     * Introduction: 专题评论列表
     * @author: 王龙
     * @email: wanglong@cdlinglu.com
     */
    public function commentLists(){

        $logic = D('Common/Special','Logic');

        //获取专题ID
        $id = intval(I('post.special_id'));
        //获取页数
        $page = I('post.page',1);
        //每页条数
        $nums = I('post.nums',20);
        //判断上传专题ID是否为空
        if(!$id)
            outPut(['code' => 300,'msg' => '参数错误'],true);

        //查询条件
        $where['special_id'] = array('eq',$id);

        outPut($logic::getComment($where,'*','create_time desc',$page,$nums),true);
    }

}